package org.map;

import java.awt.Button;
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Panel;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import org.standard.Utility;

public class MapGrid extends Panel {
	public static Image selImage;

	public MapGrid(int row, int col) {
		this.setLayout(new GridLayout(row + 1, col + 1));
		for (int i = 0; i < row * col; i++) {
			MapGridCell cell = new MapGridCell();
			this.add(cell);
		}
		Image[] im = getImageList();
		System.out.println(im[0]);
		this.add(new MapGridCellSel(im[0]));
		this.add(new MapGridCellSel(im[1]));
	}

	private Image[] getImageList() {
		Image[] pic = new Image[2];
		Image ek = Utility.loadImage("EK.png");
		pic[0] = Utility.createImage(32, 32, true);
		pic[1] = Utility.createImage(32, 32, true);
		Graphics g = pic[0].getGraphics();
		g.drawImage(ek, 0, 0, 32, 32, 3 * 32, 0, 4 * 32, 32, null);
		g = pic[1].getGraphics();
		g.drawImage(ek, 0, 0, 32, 32, 3 * 32, 32, 4 * 32, 2 * 32, null);
		g.dispose();
		return pic;
	}
}
